<?php
/**
 * @author 	 	 supfire@sohu.com
 * @copyright		 yctool.com
 * @version		 1.0
 * @name 		 roles.list.php
 * @todo 		 权限处理前台显示
 * @final 		 2009-05-05
 */
!defined("IN_YCTOOL") && exit();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
/*公用部分*/
Body{BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 20px;  BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; text-align:left; font-size:12px; color:#5a5a5a; text-align:left;}
HTML {BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px;BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px;}
SELECT {FONT-SIZE:12px; VERTICAL-ALIGN: middle;}
INPUT {FONT-SIZE:12px; VERTICAL-ALIGN: middle;
padding:1px;
BORDER-RIGHT: #ccc 1px solid; 
BORDER-TOP: #666 1px solid; 
BORDER-LEFT: #666 1px solid; 
COLOR: #333;
BORDER-BOTTOM: #ccc 1px solid; 
}
.checkbox{BORDER: #fff 0px solid;}
.redbuttom{padding:3px 2px 1px 2px; TEXT-ALIGN: center; BORDER-RIGHT: #6a6a6a 1px solid; BORDER-TOP: #fff 1px solid;BACKGROUND: #36BEFA; COLOR: #fff; BORDER-BOTTOM: #6a6a6a 1px solid; cursor:pointer;}
TEXTAREA {FONT-SIZE: 12px; VERTICAL-ALIGN: middle;}
div,form,img,ul,ol,li,dl,dt,dd {margin: 0px; padding: 0px; border: 0px;}
h1,h2,h3,h4,h5,h6 { margin:0px; padding:0px;}
table,td,tr,th{font-size:12px;}
a:link {color: #5a5a5a;text-decoration: underline;}
a:visited {color: #5a5a5a;text-decoration: underline;}
a:hover {color: #5c0e8f;text-decoration:none;} 
a:active {color: #5a5a5a;text-decoration: none;}
.area_box{ margin:10px auto; padding:0px; width:100%; text-align:left; font-size:12px; line-height:30px;}
.area_box h4{ font-size:14px;}
li {float:left; width:210px;}
-->
</style>
<script type="text/javascript">
//复选
function selectAll(chk)
{    
	var chk = document.formauth.chkAll.checked;
	for (i=0;i<document.all.length;i++)
	{
		if (document.all[i].name=="order[]")
		{
			document.all[i].checked=chk;
		}
	}
}
//删除确定
function del_t(url)
{
 	if (confirm("您确定要彻底删除吗？")) 
	{
 		document.location.href = url;
 	}
}
</script> 
<script language="javascript" src="../javascript/del_confirm.js"></script>
<title>控制后台</title>
</head>
<base target="_self" >
<body>
<div class="area_box">
<?php 
if ($operation == 'group')
{ ?>
<form name="formg" method="post" action="">
<input name="actionPost" type="hidden" value="addgroup">
[添加用户组]:
<input name="groupname" type="text" size="30" >
<select name="grouptype">
<option value="1">(用户只能属于一个)系统角色用户组</option>
<option value="2">扩展权限用户组</option>
</select>
排序<input name="grouporder" type="text" value="0" size="2">
<input type="submit" name="Submit" value="提交" class="redbuttom" />
</form>
<hr>
<?php
if ($groupOne)
{
?>
<form name="formk" method="post" action="" style="width:700px;">
<input name="actionPost" type="hidden" value="addgroup">
<input name="groupid" type="hidden" value="<?php echo $groupOne['groupid']; ?>">
[修改用户组]:
<input name="groupname" type="text" size="20" value="<?php echo $groupOne['groupname']; ?>" >
类型<select name="grouptype" id="groupypere">
<option value="1">(用户只能属于一个)系统角色用户组</option>
<option value="2">扩展权限用户组</option>
</select>
<script type="text/javascript">
document.all.groupypere.value = '<?php echo $groupOne['grouptype']; ?>';
</script>
排序<input name="grouporder" type="text" size="2" value="<?php echo $groupOne['grouporder']; ?>" > 
<input type="submit" name="Submit" value="修改" class="redbuttom" />
</form>
<hr>
<?php 
} 
if ($grouplist)
{
foreach($grouplist as $key => $item)
{ ?>
[<?php echo $item['groupid']; ?>]
 -- 
<a href="<?php echo $theurl; ?>&groupid=<?php echo $item['groupid']; ?>&operation=auth" target=_self>设置权限</a>
--
<a href="<?php echo $theurl; ?>&groupid=<?php echo $item['groupid']; ?>&operation=group" target=_self>【修改名称】</a>
-- 
<?php if ($item['grouptype'] == 1) {echo '系统角色用户组';} else{echo '扩展权限用户组';}?>
-- 
<?php echo $item['groupname']; ?>
-- 
排序<?php echo $item['grouporder']; ?>
-- 
<a href='#' onClick='del_t("<?php echo $theurl; ?>&operation=detelegroup&id=<?php echo $item['groupid']; ?>")'>删除</a>	
<br />
<?php
} 
} 
} 

//-------------以下给某个用户组添加权限处理----------------\\
if ($operation == 'auth')
{ ?>
<hr>
<form name="formauth" method="post" action="">
<input name="groupid" type="hidden" value="<?php echo $groupid; ?>">
<input name="actionPost" type="hidden" value="addauth">
授予[<?php echo $groupOne['groupname']; ?>] ID为[<?php echo $groupid; ?>] 的用户组 权限：
<br />
<div id=authlist>
<ul>
<?php if ($authlist)
{
foreach($authlist as $key => $item)
{ ?>
<li>
<input type="hidden" name="keyid[]" value="<?php echo $item['cellid']; ?>">
<input type="checkbox" name="order[]" class="checkbox" value="<?php echo $key; ?>" 
<?php
 if (in_array($item['cellid'],$groupOne['groupcells'])){ echo'checked'; } ?>
>
[<?php echo $item['cellid']; ?>]<?php echo $item['cellname']; ?>
&nbsp; &nbsp; &nbsp;
</li>
<?php
} 
}
?>
</ul>
</div>
<br />
全选 <input type="checkbox" name="chkAll" class="checkbox" onClick="selectAll()">&nbsp;
<input type="submit" name="Submit" value="  提  交  " class="redbuttom" />
</form>
<?php 
}

//-------------以下设置权限处理----------------\\
if ($operation == 'cell')
{ 
	?>
	<form name="form1" method="post" action="" style="width:800px;">
	<input name="actionPost" type="hidden" value="cell">
	描述<input name="cellname" type="text" size="20" >
	参数<input name="celltitle" type="text" size="20" >
	上级<select name="parentid" style="width:150px;">
	<option value="0">根目录</option>
	<?php
		if ($authlist)
		{
			foreach($authlist as $key => $item)
			{
				if ($item['celltype'] != 3 && $item['celltype'] != 4)
				{
					echo '<option value="'.$item['cellid'].'">'.$item['cellname'].'</option>';
				}
			}
		}
	?>
	</select> 
	类型<select name="celltype">
	<option value="1">目录</option>
	<option value="2">文件</option>
	<option value="3">GET参数</option>
	<option value="4">POST参数</option>
	</select> 
	<a href="#" title="附属权限:附加了限制条件(PAGE/GET/POST)时该条权限才起作用，正式权限:无需附件条件就起作用" style="cursor: help">权限属性</a><select name="cellallow">
	<option value="0">正式权限</option>
	<option value="1">附属权限</option>
	</select> 
	排序<input name="cellorder" type="text" size="2" value="0" > 
	<input type="submit" name="Submit" value="添加" class="redbuttom" />
	</form>
	<hr>
	<?php 
	if ($cellOne)
	{
		?>
		<form name="formk" method="post" action="" style="width:800px;">
		<input name="actionPost" type="hidden" value="cell">
		<input name="cellid" type="hidden" value="<?php echo $cellOne['cellid']; ?>">
		描述<input name="cellname" type="text" size="20" value="<?php echo $cellOne['cellname']; ?>" >
		设定<input name="celltitle" type="text" size="20" value="<?php echo $cellOne['celltitle']; ?>" >
		所属<select name="parentid" id="parentidre">
		<option value="0">一级目录</option>
		<?php
		if ($authlist)
		{
			foreach($authlist as $key => $item)
			{
				if ($item['celltype'] != 3 && $item['celltype'] != 4)
				{
					echo '<option value="'.$item['cellid'].'">'.$item['cellname'].'</option>';
				}
			}
		}
		?>
		</select> 
		类型<select name="celltype" id="celltypere">
		<option value="1">目录</option>
		<option value="2">文件</option>
		<option value="3">GET参数</option>
		<option value="4">POST参数</option>
		</select> 
		<a href="#" title="附属权限:附加了限制条件(PAGE/GET/POST)时该条权限才起作用，正式权限:无需附件条件就起作用" style="cursor: help">权限属性</a><select name="cellallow" id="cellallowre">
		<option value="0">正式权限</option>
		<option value="1">附属权限</option>
		</select> 
		<script type="text/javascript">
		document.all.parentidre.value = '<?php echo $cellOne['parentid']; ?>';
		document.all.celltypere.value = '<?php echo $cellOne['celltype']; ?>';
		document.all.cellallowre.value = '<?php echo $cellOne['cellallow']; ?>';
		</script>
		排序<input name="cellorder" type="text" size="2" value="<?php echo $cellOne['cellorder']; ?>" > 
		<input type="submit" name="Submit" value="修改" class="redbuttom" />
		</form>
		<hr>
		<?php 
	} 
	if ($authlist)
	{
		foreach($authlist as $key => $item)
		{
			?>
			<?php 
			$item['celltype'] == 1 && print '|'; 
			$item['celltype'] == 2 && print '|----|'; 
			$item['celltype'] == 3 && print '|----|----|'; 
			$item['celltype'] == 4 && print '|----|----|'; 
			?> 
			<a href="<?php echo $theurl; ?>&cellid=<?php echo $item['cellid']; ?>&operation=cell" 
			target=_self><?php echo $item['cellname']; ?>
			--
			<?php echo $item['celltitle']; ?>
			--
			排序<?php echo $item['cellorder']; ?>
			--
			修改</a>
			--
			ID:<?php echo $item['cellid']; ?>
			--
			<a href='#' onClick='del_t("<?php echo $theurl; ?>&operation=detelecell&id=<?php echo $item['cellid']; ?>")'>删除</a>	
			<br />
			<?php
		}
	} 
}
?>
<?php
//-------------以下给组件添加修改处理----------------\\
if ($operation == 'app')
{
?>
	<form name="formg" method="post" action="">
	<input name="actionPost" type="hidden" value="addapp">
	[添加] 标题:<input name="appname" type="text" size="30" >
	相对连接：<input name="appurl" type="text" size="30" >
	排序:<input name="apporder" type="text" value="0" size="2">
	<input type="submit" name="Submit" value="提交" class="redbuttom" />
	</form>
	<hr>
	<?php 
	if ($appid)
	{
	?>
	<form name="formapp" method="post" action="">
	<input name="appid" type="hidden" value="<?php echo $appid; ?>">
	<input name="actionPost" type="hidden" value="addapp">
	<input name="appname" type="text" size="30" value="<?php echo $variableapp['appname']; ?>" >
	相对连接：<input name="appurl" type="text" size="30" value="<?php echo $variableapp['appurl']; ?>" >
	排序:<input name="apporder" type="text" value="<?php echo $variableapp['apporder']; ?>" size="2">
	<input type="submit" name="Submit" value="提交" class="redbuttom" />
	</form>
	<hr>
	<?php
	}
	?>
	<?php 
	if ($userapp)
	{
	?>
			<div id=authlist>
			<?php
			foreach($userapp as $key => $item)
			{
				?>
					<ul>
				[<?php echo $key; ?>] <?php echo $item['appname']; ?>  <?php echo $item['apporder']; ?>
<a href="<?php echo $theurl; ?>&appid=<?php echo $key; ?>&operation=app" target=_self>【修改】</a>
<a href='javascript:del_t("<?php echo $theurl; ?>&operation=app&actiondel=appdel&id=<?php echo $key; ?>")' onClick=''>删除</a>	
				&nbsp; &nbsp; &nbsp;
				</ul>
				<?php
			}
			?>
		
			</div>
	<?php
	}
	?>
<?php 
}
?>
</div>
</body>
</html>